package com.itheima.youdianda.controller;

import com.itheima.youdianda.common.R;
import com.itheima.youdianda.pojo.YddAdvimg;
import com.itheima.youdianda.service.YddAdvimgService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 广告图
 */
@RestController
@RequestMapping("ydd_advimg")
@Slf4j
public class YddAdvimgController {
    @Autowired
    private YddAdvimgService service;

    /**
     * 广告图详情
     *
     * @return
     */
    @GetMapping("rowInfo")
    public R rowInfo(Integer id) {
        return service.rowInfo(id);
    }

    /**
     * 广告图列表分页
     *
     * @param page
     * @param limit
     * @param advimgpos
     * @param advimgdesc
     * @return
     */
    @GetMapping("list")
    public R yddAdvimgList(@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                           @RequestParam(value = "limit", required = false, defaultValue = "10") Integer limit,
                           String advimgpos, String advimgdesc) {
        return service.yddAdvimgList(page, limit, advimgpos, advimgdesc);
    }

    /**
     * 广告图修改
     *
     * @param yddAdvimg
     * @return
     */
    @PostMapping("update")
    public R yddAdvimgUpdate(@RequestBody YddAdvimg yddAdvimg) {
        return service.yddAdvimgUpdate(yddAdvimg);
    }

    /**
     * 广告图删除
     *
     * @param id
     * @return
     */
    @GetMapping("del")
    public R del(Integer id) {
        return service.del(id);
    }

    /**
     * 广告图添加
     *
     * @param yddAdvimg
     * @return
     */
    //TODO 理解不了为什么接口文档用GET
    @PostMapping("add")
    public R yddAdvimgAdd(@RequestBody YddAdvimg yddAdvimg) {
        return service.yddAdvimgAdd(yddAdvimg);
    }


}



